<template>
  <div class="moreOperation clearfix">
    <div class="btn-blue btn cp" v-if="current_contact.id_type === 1 && !contactInfo.in_contact" @click="addFriend">添加</div>
    <img src="@/assets/message/more.png" class="cp" alt="" @click="openChatDetail">
  </div>
</template>

<script>
export default {
  data () {
    return {
      inContact: true
    }
  },
  computed: {
    current_contact () {
      return this.$store.state.chatInformation.current_contact
    },
    // 当前联系人信息
    contactInfo () {
      return this.tools.getContactInfo(this.current_contact.id, this.current_contact.id_type)
    }
  },
  components: {
  },
  methods: {
    // 打开聊天详情
    openChatDetail () {
      this.$store.commit('message/set_ifShowChatDetail', true)
    },
    // 添加好友
    addFriend () {
      this.$store.dispatch('addressList/getUserDetail', this.current_contact.id).then(res => {
        if (res.data && res.data.code === 200) {
          res.data.data.info.user_img = this.tools.getAvatar(this.current_contact.id, 1)
          this.$store.commit('addressList/set_userInfo', res.data.data.info)
          this.$emit('addFriend')
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.moreOperation {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0;
  .btn {
    width: 64px;
    height: 32px;
    border-radius: 4px;
    display: inline-block;
    color: #fff;
    font-size: 14px;
    line-height: 32px;
    text-align: center;
    vertical-align: middle;
    margin-right: 20px;
  }
  img {
    width: 24px;
    vertical-align: middle;
  }
}
</style>
